﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Edgar.Entities;
using System.Xml.Serialization;
using System.IO;
using Edgar.Entities.MasterData;
using Edgar.Entities.Items;

namespace Edgar.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            MeleeWeapon sword = new MeleeWeapon()
            {
                Name = "Schwert",
                PriceSilver = 16,
                DamageStep = 5,
                Size = 3,
                MinimumStrength = 10,
                WeightPound = 18,
                Category = "Waffen",
                SubCategory = "Nahkampfwaffen",
                Source = "Grundbuch"
            };

            Item item = new Item()
            {
                Name = "Scheiss Kleidung",
                PriceCopper = 13,
                WeightOunce = 2,
                Source = "Grundbuch", Category = "Kleidung", SubCategory = "Pakete"
            };

            Warehouse wh = new Warehouse();
            wh.MeleeWeapons = new List<MeleeWeapon>();
            wh.MeleeWeapons.Add(sword);
            wh.ProjectileWeapons = new List<ProjectileWeapon>();
            wh.ProjectileWeapons.Add(new ProjectileWeapon() { Name = "Flitzebogen", RangeShort="2-50", RangeMedium="51-175", RangeLong="176-275", Source = "Grundbuch", Category = "Waffen", SubCategory = "Projektilwaffen" });
            wh.MissileWeapons = new List<MissileWeapon>();
            wh.MissileWeapons.Add(new MissileWeapon() { Name = "Stein", RangeShort = "2-50", RangeMedium = "51-175", RangeLong = "176-275", Source = "Grundbuch", Category = "Waffen", SubCategory = "Wurfwaffen" });
            wh.Armors = new List<Armor>();
            wh.Armors.Add(new Armor() { Name = "Maraskanischer Hartholzharnisch", Source = "Grundbuch", Category = "Rüstungen" });
            wh.Shields = new List<Shield>();
            wh.Shields.Add(new Shield() { Name = "Furzschild", Source = "Grundbuch", Category = "Schilde" });
            wh.Items = new List<Item>();
            wh.Items.Add(item);

            using (TextWriter tw = new StreamWriter("items.xml"))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Warehouse));
                serializer.Serialize(tw, wh);
            }
        }

        public static Edgar.Entities.Characteristics.Character GetDummyCharacter()
        {
            var character = new Edgar.Entities.Characteristics.Character();
            return character;
        }

        public static Discipline GetDummyDiscipline()
        {
            var discipline = new Discipline();
            discipline.Name = "Schütze";
            return discipline;
        }

        public static void WriteDummyRulebook()
        {
            Rulebook rulebook = new Rulebook();

            rulebook.AttributeCharacteristics.Add(new AttributeCharacteristics
            {
                LimitDeath = 20,
                LimitFaint = 10,
                LimitWound = 6,
                MysticArmor = 2,
                RegenerationsPerDay = 3,
                ResistenceValue = 10,
                SpeedCombat = 12,
                SpeedNormal = 24,
                AttributeValue = 20,
                WeightCarrying = 500,
                WeightLifting = 1000
            });

            rulebook.StepDices.Add(new StepDice { Step = 12, Dice = "W20+W4" });
            rulebook.StepDices.Add(new StepDice { Step = 13, Dice = "W20+W6" });

            rulebook.Disciplines.Add(new Discipline
            {
                Name = "Luftpirat",
                ExcludedRaceNames = new List<string> { "Elf", "Obsidianer", "Windling" },
                Talents = new List<DisciplineTalent>{ 
                    new DisciplineTalent{ Circle = 1, TalentName = "Feuerblut"},
                    new DisciplineTalent{ Circle = 1, TalentName = "Hieb Ausweichen"}, 
                    new DisciplineTalent{ Circle = 2, TalentName = "Schildangriff"}}
            });

            rulebook.Races.Add(new Race
            {
                Name = "Troll",
                AttributeModifications = new List<AttributeModification>{
                    new AttributeModification{ AttributeName="Stärke", Modificator = 5 },
                    new AttributeModification{ AttributeName="Wahrnehmung", Modificator = -1 }
                },
                Karma = new Karma
                {
                    Cost = 100,
                    Die = "W3",
                    Maximum = 25,
                    Starting = 5
                },
                SpeedModification = 1,
                RaceSkills = new List<RaceSkill>{
                    new  RaceSkill{Description = "Infrarotsicht"}
                }
            });

            rulebook.Talents.Add(
                new Talent
                {
                    Name = "Tiere heilen",
                    Attribute = "Zähigkeit",
                    Action = true,
                    Skill = false,
                    NeedsKarma = false,
                    Exhaustion = 0,
                    DisciplineTalentOf = new List<string> { "Steppenreiter", "Tiermeister" }
                });
            rulebook.Talents.Add(
                new Talent
                {
                    Name = "Tigersprung",
                    Action = false,
                    Skill = false,
                    NeedsKarma = false,
                    Exhaustion = 1,
                    DisciplineTalentOf = new List<string>()
                });

            using (TextWriter tw = new StreamWriter("rulebook.xml"))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Rulebook));
                serializer.Serialize(tw, rulebook);
            }
        }
    }
}
